package ar.com.ctrln.view.menu.ventas;

import java.util.LinkedList;
import java.util.List;

import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Window;

public class MenuComposerVentas extends GenericForwardComposer<Component> {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7823196034355663611L;
	/**
		 * 
		 */
	Window wDashboard;
	List<Component> heap = new LinkedList<Component>();
	
	@Override
	public void doAfterCompose(Component comp) throws Exception {
		super.doAfterCompose(comp);
		Component window = Executions.createComponents(
				"/zul/ventas/dashboard.zul", wDashboard, null);
		heap.add(window);
		
	}

	/**
	 * Metodos de Eventos del Menú
	 */

	public void onClick$bRegistrarServicioCliente$wMenu$iMenu() {

		Component window = Executions.createComponents(
				"/zul/ventas/contratacion/registrarServicioCliente.zul",
				wDashboard, null);
		heap.add(window);

	}
	public void onClick$bconsultarServicioCliente$wMenu$iMenu() {

		Component window = Executions.createComponents(
				"/zul/ventas/contratacion/consultarServicioCliente.zul",
				wDashboard, null);
		heap.add(window);
	}
	
	public void onClick$bRegistrarCategoria$wMenu$iMenu() {

		Component window = Executions.createComponents(
				"/zul/ventas/servicios/registrarCategoria.zul",
				wDashboard, null);
		heap.add(window);
	}
	public void onClick$bConsultarCategoria$wMenu$iMenu() {

		Component window = Executions.createComponents(
				"/zul/ventas/servicios/consultarCategoria.zul",
				wDashboard, null);
		heap.add(window);
	}

	public void onClick$bRegistrarServicio$wMenu$iMenu() {

		Component window = Executions.createComponents(
				"/zul/ventas/servicios/registrarServicio.zul",
				wDashboard, null);
		heap.add(window);
	}
	public void onClick$bConsultarServicio$wMenu$iMenu() {

		Component window = Executions.createComponents(
				"/zul/ventas/servicios/consultarServicio.zul",
				wDashboard, null);
		heap.add(window);
	}
	public void onClick$bRegistrarFactibilidadServicio$wMenu$iMenu() {

		Component window = Executions.createComponents(
				"/zul/ventas/solicitud/registrarFactibilidadServicio.zul",
				wDashboard, null);
		heap.add(window);
	}
	public void onClick$bConsultarFactibilidadServicio$wMenu$iMenu() {

		Component window = Executions.createComponents(
				"/zul/ventas/solicitud/consultarFactibilidadServicio.zul",
				wDashboard, null);
		heap.add(window);
	}
	public void onClick$bRegistrarSolicitudCliente$wMenu$iMenu() {

		Component window = Executions.createComponents(
				"/zul/ventas/solicitud/registrarSolicitudCliente.zul",
				wDashboard, null);
		heap.add(window);
	}
	public void onClick$bConsultarSolicitudCliente$wMenu$iMenu() {

		Component window = Executions.createComponents(
				"/zul/ventas/solicitud/consultarFactibilidad.zul",
				wDashboard, null);
		heap.add(window);
	}
	public void onClick$bConsultarCotizacion$wMenu$iMenu() {

		Component window = Executions.createComponents(
				"/zul/ventas/cotizacion/consultarCotizacion.zul",
				wDashboard, null);
		heap.add(window);
	}
	public void onClick$bRegistrarCotizacion$wMenu$iMenu() {

		Component window = Executions.createComponents(
				"/zul/ventas/cotizacion/registrarCotizacion.zul",
				wDashboard, null);
		heap.add(window);
	}

	public void onClose(Event evt) {

		for (Component comp : heap) {

			if (((Window) comp).getTitle() == ((Window) evt.getTarget())
					.getTitle()) {
				System.out.println("Eliminando Ventana: "
						+ ((Window) evt.getTarget()).getTitle());
				heap.remove(comp);
				comp.detach();

			}
		}
		for (Object comp : wDashboard.getChildren()) {

			System.out.println("Dashboard: " + comp.toString());

		}
		wDashboard.getChildren().clear();
		Component window = Executions.createComponents(
				"/zul/administracion/dashboard.zul", wDashboard, null);
		heap.add(window);
	}
}
